﻿/*****************************************************************//**
 * @file    FITKGraphObjectPostModel.h
 * @brief   Post graph object for model.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-05-20
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTPOSTMODEL_H__
#define __FITKGRAPHOBJECTPOSTMODEL_H__

#include "FITKGraphObjectPostModelBase.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class QVariant;

class vtkExtractSelection;
class vtkAlgorithmOutput;
class vtkAlgorithm;

namespace Interface
{
    class FITKAbstractStructuralPostVTK;
}

namespace Exchange
{
    class FITKGraphObjectModelHighlighting;
}

namespace Exchange
{
    /**
     * @brief   Post graph object for model.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-05-20
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectPostModel : public FITKGraphObjectPostModelBase
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectPostModel, FITKGraphObjectPostModelBase);
        FITKCLASS(Exchange, FITKGraphObjectPostModel);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data( If the post data is import with file, the case data maybe nullptr)
         * @param   postData: The input model's post data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-20
         */
        FITKGraphObjectPostModel(AbaqusData::FITKDataCase* caseData, Interface::FITKAbstractStructuralPostVTK* postData);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-20
         */
        virtual ~FITKGraphObjectPostModel();

        /**
         * @brief   Enable or disable the deformation.[override]
         * @param   isOn: Is on
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-01
         */
        void setEnableDeform(bool isOn) override;

        /**
         * @brief   Set if the graph object can be picked.[override]
         * @param   isPickable: Pickable
         * @param   dim: The dimision of the pickable object( -1 means the whole graph object )[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-05
         */
        void setPickable(bool isPickable, int dim = -1) override;

        /**
         * @brief   Check if the model has visible cut view, if exist, then hide itself.
         * @return  If there is at least one visible cut view
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-01
         */
        bool hasVisibleCutView();

        /**
         * @brief   Get the visibility from the data object.[override]
         * @return  The visibility
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-06
         */
        bool getDataVisibility() override;

        /**
         * @brief   Update the actors and scalar bar.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-01
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Highlight the post model or display group.[override]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-11
         */
        void highlight(QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the post model or display group.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-11
         */
        void disHighlight() override;

        /**
         * @brief   Highlight the post model display group.[override]
         * @param   details: The details about highlighting.( The id of the spring pair need to be highlighted. )[default]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-11
         */
        void advanceHighlight(QVariant details, QColor color = QColor()) override;

        /**
         * @brief   Dis-advance highlight the post model display group.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-11
         */
        void disAdvanceHighlight() override;

        /**
         * @brief   Get the algorithm output port for calculation.[virtual][override]
         * @param   forRendering: The output type[default]
         * @return  The output port
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-22
         */
        virtual vtkAlgorithmOutput* getOutputPort(bool forRendering = false) override;

        /**
         * @brief   Get the algorithm output dataset for calculation or visualization.[virtual][override]
         * @param   forRendering: The output type[default]
         * @return  The output dataset
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-22
         */
        virtual vtkDataSet* getOutput(bool forRendering = false) override;

        /**
         * @brief   Get the feature data of the post model.[override]
         * @return  The mesh feature
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-22
         */
        Interface::FITKMeshFeatureVTK* getMeshFeature() override;

    private:
        /**
         * @brief   Get the post model output port.
         * @param   isVolume: Is the output for rendering volume[default]
         * @return  The output port
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-05
         */
        vtkAlgorithmOutput* getPostModelOutput(bool isVolume = false);

    private:
        /**
         * @brief   The output algorithm for the post model.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-20
         */
        vtkAlgorithm* m_postDataOutput{ nullptr };

        /**
         * @brief   The extractor for display group.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-05
         */
        vtkExtractSelection* m_groupExtractor{ nullptr };

        /**
         * @brief   The post model highlight graph object.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-11
         */
        FITKGraphObjectModelHighlighting* m_graphObjHighlight{ nullptr };
    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTPOSTMODEL_H__
